

package org.example.design.designmode.facadepattern.sellbubbles.facade;



/**
 *  建造者加单例模式
 *  单例：私有构造函数
 *    创建获取实例静态方法
 *    加锁操作
 * 建造者：定义私有实例、操作该实例并返回
 *
 */

public class MenuBuilder {
    private Menu menu = new Menu();
    private  static volatile MenuBuilder menuB;
    private MenuBuilder(){}

    public static MenuBuilder getInstance(){
        if (menuB==null){
            synchronized (MenuBuilder.class){
                if (menuB==null){
                    menuB = new MenuBuilder();
                }
            }
        }
        return menuB;

    }

    public MenuBuilder addwenda(){
        menu.setWenda("问答");
        return this;
    }


    public MenuBuilder addwenzhang(){
        menu.setWenzhang("文章");
        return this;
    }

    public MenuBuilder addjingpinke(){
        menu.setJingpinke("精品课");
        return this;
    }

    public MenuBuilder addmaopao(){
        menu.setMaopao("冒泡");
        return this;
    }

    public MenuBuilder addsahngcheng(){
        menu.setSahngcheng("商城");
        return this;
    }

    public MenuBuilder addtiku(){
        menu.setTiku("题库");
        return this;
    }

    public MenuBuilder addzuoye(){
        menu.setZuoye("作业");
        return this;
    }

    public MenuBuilder addyonghuguanli(){
        menu.setYonghuguanli("用户管理");
        return this;
    }
    public MenuBuilder addzuoyezhengli(){
        menu.setZuoyezhengli("作业整理");
        return this;
    }


    @Override
    public String toString() {
        return "menuBuilder{" +
                "menu=" + menu.toString() +
                '}';
    }
}
